export let data

// ** Get initial Data
data = [
  {
    name: '张凯',
    account: '13882837272',
    grades: '32',
    role: '二级管理员',
    time: '2023-12-24 14:00',
    type: {
      value: 0,
      label: '用户注册',
    },
    status: {
      value: 1,
      label: '已激活',
    },
  },
  {
    name: '李玉杰',
    account: '13882837272',
    role: '普通用户',
    grades: '32',
    type: {
      value: 1,
      label: '工作人员创建',
    },
    status: {
      value: 1,
      label: '已激活',
    },
    time: '2023-12-24 14:00',
  },
  {
    name: '周某',
    address: '某某小区',
    role: '普通用户',
    account: '13882837272',
    type: {
      value: 1,
      label: '工作人员创建',
    },
    status: {
      value: 0,
      label: '已冻结',
    },
    grades: '32',
    time: '2023-12-24 14:00',
  },
]

const statusEnum = {
  0: '#ea5455',
  1: '#56affd',
}
// ** Table Common Column
export const columns = (handleEdit, handleDelete, toggleStatus) => [
  {
    name: '用户名',
    minWidth: '100px',
    cell: (row) => row.name,
  },
  {
    name: '账号',
    minWidth: '150px',
    selector: (row) => row.account,
  },
  {
    name: '角色',
    minWidth: '150px',
    selector: (row) => row.role.label,
  },
  {
    name: '账户状态',
    minWidth: '100px',
    cell: (row) => (
      <span
        style={{
          color: statusEnum[row.status && row.status.value],
          border: `1px solid ${statusEnum[row.status && row.status.value]}`,
          borderRadius: '4px',
          padding: '1px 4px',
        }}
      >
        {row.status.label}
      </span>
    ),
  },
  {
    name: '操作',
    width: '200px',
    selector: (row) => (
      <div
        className="column-action d-flex align-items-center"
        style={{ color: '#7367f0' }}
      >
        <div
          className="cursor-pointer"
          style={{
            color: `${row.status && row.status.value === 0 ? '' : '#cbcbcb'}`,
          }}
          onClick={() => toggleStatus(row)}
        >
          激活
        </div>
        <div
          className="ms-50 cursor-pointer"
          style={{
            color: `${row.status && row.status.value === 1 ? '' : '#cbcbcb'}`,
          }}
          onClick={() => toggleStatus(row)}
        >
          冻结
        </div>
        <div
          className="ms-50 cursor-pointer"
          onClick={() => {
            handleEdit(row._id)
          }}
        >
          编辑
        </div>
        <div
          className="ms-50 cursor-pointer"
          onClick={() => {
            handleDelete(row._id)
          }}
        >
          删除
        </div>
      </div>
    ),
  },
]
